package com.zhixing.order.websocket;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zhixing.order.domain.vo.OrderGrabInfoVO;
import jakarta.websocket.Encoder;

public class DriverWebSocketEncoder implements Encoder.Text<OrderGrabInfoVO> {

    private static final ObjectMapper objectMapper = new ObjectMapper();

    @Override
    public String encode(OrderGrabInfoVO orderGrabInfoVO) {
        try {
            return objectMapper.writeValueAsString(orderGrabInfoVO);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }
}
